package main

//推荐参考blog:http://www.cnblogs.com/mafeng/p/6225777.html

import (
	_ "gopkg.in/yaml.v2"
	"fmt"
	"io/ioutil"
	yaml "github.com/go-yaml/yaml"
)

type T struct {
   User struct{
	   Name string "yaml:name"
	   Password string "yaml:password"
	   Admin struct{
		Guest string "yaml:guest"
		Tax string  "ymal:tax"
	   }
   }
}

func Add(){
	defer func(){
		if err:=recover();err!=nil{
			fmt.Println("发生panic->",err)
		}
	}()
	panic("123")
}

func main() {
	Add() //这个方法添加recover()之后，下面的代码会正常执行
	fmt.Println("123333")
	t:=T{}
	data,err:=ioutil.ReadFile("E:\\JetBrains\\GoglandProjects\\beego\\bin\\data.yml")
	if err!=nil{
		fmt.Println(err)
		panic(err)
	}
	err=yaml.Unmarshal(data,&t)
	fmt.Println("error->",err)
	fmt.Println(t)
}
